package com.example.demo.mapper;

import com.example.demo.dto.SearchInfo;
import com.example.demo.entity.Chukusunhuai;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository()
public interface Chukusunhuai_Mapper extends BaseMapper<Chukusunhuai>{
	
	@Select("SELECT Chukusunhuai.* ,cangku.chanpinname chanpinname"
	        + " FROM Chukusunhuai join cangku on Chukusunhuai.chanpinid=cangku.id ${where} ${limitstr}")
	public List<Chukusunhuai> select(SearchInfo info);
	
	@Select("SELECT COUNT(1) FROM Chukusunhuai " +
			" join cangku on Chukusunhuai.chanpinid=cangku.id ${where}")
	public long selectCount(SearchInfo info);
	
	@Insert("INSERT INTO Chukusunhuai (chukujiluid,chanpinid, number,time,bufa) VALUES (#{chukujiluid}, #{chanpinid}, #{number},#{time},#{bufa})")
	public void insert(Chukusunhuai Chukusunhuai);
	
	@Update("UPDATE Chukusunhuai SET chukujiluid = #{chukujiluid}, chanpinid = #{chanpinid}, "
	        + " number = #{number} , bufa=#{bufa} WHERE id = #{id}")
	public void update(Chukusunhuai Chukusunhuai);
	
	
	@Delete("DELETE FROM Chukusunhuai WHERE id = #{id}")
	public void delete(int id);
	
	@Select("SELECT * FROM Chukusunhuai WHERE id = #{id}")
	public Chukusunhuai selectById(int id);
	
}
